library(dplyr)
#library(psych) #for pairs.panels, but could use other packages, e.g. GGalley
library(lavaan)
library(semPlot)
library(DiagrammeR)
library(ggplot2)
library(tidyr)
combined=read.csv("data/monthly_averages/monthly_data_compiled_regions.csv",stringsAsFactors = F)
cnames=read.csv("analysis/column_names_region_monthly.csv", stringsAsFactors = F)
dsub=filter(combined, Year>=1995) %>% arrange(Region,Year,Month)
focaldata=dsub[,cnames$Datacolumn]
fvars=cnames$Shortname
colnames(focaldata)=fvars
regions=unique(focaldata$region)
regionorder=c("Far West","West","North","South")
focaldata=focaldata%>%
mutate(decyear=year+(month-1)/12,
sinmon=sin(2*pi/12*month),
cosmon=cos(2*pi/12*month))
focaldata = focaldata %>%
mutate(tzoop=hcope+clad+mysid+pcope,
tzoop_c=hcope_c+clad_c+mysid_c+pcope_c,
tzoop_e=hcope_e+clad_e+mysid_e+pcope_e,
hzoop=hcope+clad,
hzoop_c=hcope_c+clad_c,
hzoop_e=hcope_e+clad_e,
pzoop=mysid+pcope,
pzoop_c=mysid_c+pcope_c,
pzoop_e=mysid_e+pcope_e)
fvars=c(fvars,"tzoop","tzoop_c","tzoop_e",
"hzoop","hzoop_c","hzoop_e",
"pzoop","pzoop_c","pzoop_e")
cnames=rbind(cnames,data.frame(Longname=NA,Shortname=c("tzoop","tzoop_c","tzoop_e",
"hzoop","hzoop_c","hzoop_e",
"pzoop","pzoop_c","pzoop_e"),
Diagramname=c("Total Zooplankton\nBiomass",
"Total Zooplankton\nAbundance",
"Total Zooplankton\nEnergy",
"Herbivorous Zooplankton\nBiomass",
"Herbivorous Zooplankton\nAbundance",
"Herbivorous Zooplankton\nEnergy",
"Predatory Zooplankton\nBiomass",
"Predatory Zooplankton\nAbundance",
"Predatory Zooplankton\nEnergy"),
Datacolumn=NA,Log="yes"))
#focal variables
varnames=c("temp","flow","nitrate","ammonia","dophos","chla","hcope","clad","amphi","pcope","mysid","potam","corbic","sside","estfish_bsot","estfish_bsmt","tzoop","tzoop_c","tzoop_e","hzoop","pzoop")
#labels for lagged vars
cnameslag=cnames
cnameslag$Shortname=paste0(cnameslag$Shortname,"_1")
cnameslag$Diagramname=paste(cnameslag$Diagramname,"(t-1)")
cnameslag=rbind(cnames,cnameslag)
source("analysis/myLavaanPlot.r")
Notes:
Determine which vars are appropriate for which regions and at what lags.
Write out path diagram for each region.
Model with and without fish, probably, because of missing data.
Log transform, scale.
Within and across regions.
Create set with regional monthly means removed.
#log transform
logvars=fvars[cnames$Log=="yes"]
logtrans=function(x) {
x2=x[which(!is.na(x))]
if(any(x2==0)) {log(x+min(x2[which(x2>0)],na.rm=T))}
else {log(x)}
}
focaldatalog = focaldata %>%
mutate_at(logvars,logtrans)
#scale data
fdr0=focaldatalog
tvars=fvars[-(1:3)]
#scaled within regions
fdr=fdr0 %>%
group_by(region) %>%
#scale
mutate_at(tvars,scale) %>%
#lag
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled within regions, remove monthly means
fdr_ds=fdr %>%
group_by(region,month) %>%
mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
ungroup() %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled across regions
fdr1=fdr0 %>%
#scale
mutate_at(tvars,scale) %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled across regions, monthly means removed
fdr1_ds=fdr1 %>%
group_by(region,month) %>%
mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
ungroup() %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
Data availability by series and region (prop zeros and prop missing)
FW: ignore clad, corbic, sside
W: ignore corbic, sside
S: ignore potam
dataavail=focaldata %>%
gather(var, value, 4:length(fvars)) %>%
group_by(region, var) %>%
summarize(
propmissing=length(which(is.na(value)))/length(value),
propzeros=length(which(value==0))/length(which(!is.na(value)))) %>%
as.data.frame()
#these variables should not be used (too many zeros)
filter(dataavail,propzeros>0.5 | is.na(propzeros))
## region var propmissing propzeros
## 1 Far West clad 0.1382637 0.9514925
## 2 Far West clad_c 0.1382637 0.9514925
## 3 Far West clad_e 0.1382637 0.9514925
## 4 Far West corbic 0.1382637 1.0000000
## 5 Far West marfish_bsot 0.4565916 0.6508876
## 6 Far West sbass_bsmt 0.4951768 0.7707006
## 7 Far West sbass_bsot 0.4565916 0.7218935
## 8 Far West smelt_bsmt 0.4951768 0.9808917
## 9 Far West smelt_bsot 0.4565916 0.9940828
## 10 Far West sside 1.0000000 NaN
## 11 North lfin_bsmt 0.5144695 0.8741722
## 12 North lfin_bsot 0.4694534 0.9393939
## 13 North marfish_bsmt 0.5144695 0.9735099
## 14 North marfish_bsot 0.4694534 0.9939394
## 15 North sbass_bsmt 0.5144695 0.5496689
## 16 North smelt_bsot 0.4694534 0.8242424
## 17 South lfin_bsmt 0.5128205 1.0000000
## 18 South lfin_bsot 0.4679487 1.0000000
## 19 South marfish_bsmt 0.5128205 1.0000000
## 20 South marfish_bsot 0.4679487 1.0000000
## 21 South potam 0.1378205 0.9702602
## 22 South sbass_bsmt 0.5128205 0.6513158
## 23 South smelt_bsmt 0.5128205 0.8486842
## 24 South smelt_bsot 0.4679487 0.9156627
## 25 West corbic 0.1350482 0.8066914
## 26 West marfish_bsot 0.4598071 0.9047619
## 27 West smelt_bsmt 0.4983923 0.5128205
## 28 West smelt_bsot 0.4598071 0.7619048
## 29 West sside 1.0000000 NaN
#these variables have lots of missing data
filter(dataavail,propmissing>0.45 | is.na(propmissing))
## region var propmissing propzeros
## 1 Far West estfish_bsmt 0.4951768 0.165605096
## 2 Far West estfish_bsot 0.4565916 0.201183432
## 3 Far West lfin_bsmt 0.4951768 0.356687898
## 4 Far West lfin_bsot 0.4565916 0.248520710
## 5 Far West marfish_bsmt 0.4951768 0.006369427
## 6 Far West marfish_bsot 0.4565916 0.650887574
## 7 Far West sbass_bsmt 0.4951768 0.770700637
## 8 Far West sbass_bsot 0.4565916 0.721893491
## 9 Far West smelt_bsmt 0.4951768 0.980891720
## 10 Far West smelt_bsot 0.4565916 0.994082840
## 11 Far West sside 1.0000000 NaN
## 12 North estfish_bsmt 0.5144695 0.152317881
## 13 North estfish_bsot 0.4694534 0.236363636
## 14 North lfin_bsmt 0.5144695 0.874172185
## 15 North lfin_bsot 0.4694534 0.939393939
## 16 North marfish_bsmt 0.5144695 0.973509934
## 17 North marfish_bsot 0.4694534 0.993939394
## 18 North sbass_bsmt 0.5144695 0.549668874
## 19 North sbass_bsot 0.4694534 0.260606061
## 20 North smelt_bsmt 0.5144695 0.403973510
## 21 North smelt_bsot 0.4694534 0.824242424
## 22 South estfish_bsmt 0.5128205 0.197368421
## 23 South estfish_bsot 0.4679487 0.180722892
## 24 South lfin_bsmt 0.5128205 1.000000000
## 25 South lfin_bsot 0.4679487 1.000000000
## 26 South marfish_bsmt 0.5128205 1.000000000
## 27 South marfish_bsot 0.4679487 1.000000000
## 28 South sbass_bsmt 0.5128205 0.651315789
## 29 South sbass_bsot 0.4679487 0.204819277
## 30 South smelt_bsmt 0.5128205 0.848684211
## 31 South smelt_bsot 0.4679487 0.915662651
## 32 West estfish_bsmt 0.4983923 0.019230769
## 33 West estfish_bsot 0.4598071 0.077380952
## 34 West lfin_bsmt 0.4983923 0.250000000
## 35 West lfin_bsot 0.4598071 0.392857143
## 36 West marfish_bsmt 0.4983923 0.115384615
## 37 West marfish_bsot 0.4598071 0.904761905
## 38 West sbass_bsmt 0.4983923 0.294871795
## 39 West sbass_bsot 0.4598071 0.184523810
## 40 West smelt_bsmt 0.4983923 0.512820513
## 41 West smelt_bsot 0.4598071 0.761904762
## 42 West sside 1.0000000 NaN
(only sig correlations shown… no correction for multiple comparisons)
Other notes:
Detrended fish indices are NOT correlated in S!
Nitrate and ammonia are positively correlated, max at lag 0 all regions.
Nitrate and dophos are positively correlated, max at lag 0 all regions.
Ammonia and dophos are positively correlated, lag 0 for FW and S, ammonia lags dphos by 3 months in W and N.
Chla nitrate neg correlated, lag 0.
Chla ammonia neg correlated, lag 0.
Chla dophos relationship unclear.
High flow 2-4 month prev = high chla
Hcope lags chla by 1, positive, except FW.
Clad seem to precede chla by 2, positive.
Amphi relationship unclear, prob bc not eating chla in water column.
In N and W, chla lags potam, negative. The opposite in W.
Mysid and hcope postive, lag 0.
In S and W, hcope lags pcope, negative.
This doesn’t consider time lags.
l_modelsfw = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"hcope","amphi","pcope",
"tzoop+amphi","hzoop+amphi","pzoop+amphi",
"hcope+pcope","hcope+amphi","pcope+amphi",
"hcope+pcope+amphi"))
l_models = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"mysid","hcope","clad","amphi","pcope",
"tzoop+amphi","hzoop+amphi","pzoop+amphi","pzoop+clad",
"hzoop+mysid","pzoop+clad+hcope",
"hcope+pcope","hcope+amphi","pcope+amphi","hcope+clad",
"amphi+clad","pcope+clad","mysid+amphi",
"hcope+clad+mysid",
"hcope+clad+mysid+pcope",
"hcope+mysid",
"hcope+mysid+pcope",
"hcope+mysid+amphi"))
l_modelss = data.frame(l_model = c("tzoop","tzoop_c",
"hzoop","hzoop+pzoop","pzoop",
"hcope","amphi","pcope","clad",
"tzoop+amphi","hzoop+amphi","pzoop+amphi","pzoop+clad",
"pzoop+clad+hcope",
"hcope+pcope","hcope+amphi","pcope+amphi","hcope+clad",
"amphi+clad","pcope+clad",
"hcope+pcope+amphi","hcope+pcope+clad",
"hcope+pcope+amphi+clad"))
#Midwater Trawl
fwestmods = purrr::map(l_modelsfw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="Far West" & !is.na(amphi) & !is.na(tzoop))))
names(fwestmods)=l_modelsfw$l_model
bbmle::AICctab(fwestmods,weights=T,delta=T)
## dAICc df weight
## hcope+pcope+amphi 0.0 5 0.5632
## hzoop+amphi 1.8 4 0.2284
## hcope+amphi 3.3 4 0.1060
## pcope+amphi 5.5 4 0.0355
## tzoop+amphi 6.6 4 0.0212
## amphi 7.7 3 0.0121
## pzoop+amphi 8.0 4 0.0106
## hzoop 8.1 3 0.0096
## hcope 9.6 3 0.0047
## hcope+pcope 9.8 4 0.0043
## hzoop+pzoop 10.2 4 0.0034
## tzoop 14.1 3 <0.001
## pcope 15.6 3 <0.001
## tzoop_c 16.4 3 <0.001
## pzoop 16.6 3 <0.001
westmods = purrr::map(l_models$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="West" & !is.na(amphi) & !is.na(tzoop))))
names(westmods)=l_models$l_model
bbmle::AICctab(westmods,weights=T,delta=T)
## dAICc df weight
## mysid+amphi 0.0 4 0.3392
## pzoop+amphi 2.0 4 0.1273
## hcope+mysid+amphi 2.0 5 0.1244
## amphi+clad 2.2 4 0.1137
## amphi 2.6 3 0.0941
## tzoop+amphi 3.9 4 0.0489
## pcope+amphi 3.9 4 0.0481
## hcope+amphi 4.5 4 0.0353
## hzoop+amphi 4.6 4 0.0332
## hcope+clad+mysid+pcope 6.4 6 0.0141
## hcope+mysid+pcope 7.9 5 0.0065
## mysid 8.5 3 0.0049
## pcope+clad 9.9 4 0.0023
## hzoop+mysid 10.4 4 0.0019
## hcope+mysid 10.5 4 0.0018
## hcope+clad+mysid 10.7 5 0.0016
## pcope 13.2 3 <0.001
## pzoop+clad 13.6 4 <0.001
## clad 13.6 3 <0.001
## pzoop 13.7 3 <0.001
## hcope+clad 14.4 4 <0.001
## hcope+pcope 14.5 4 <0.001
## pzoop+clad+hcope 15.3 5 <0.001
## tzoop 15.7 3 <0.001
## hzoop+pzoop 15.8 4 <0.001
## hcope 16.4 3 <0.001
## hzoop 16.7 3 <0.001
## tzoop_c 16.7 3 <0.001
northmods = purrr::map(l_models$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="North" & !is.na(amphi) & !is.na(tzoop))))
names(northmods)=l_models$l_model
bbmle::AICctab(northmods,weights=T,delta=T)
## dAICc df weight
## tzoop_c 0.0 3 0.1695
## hcope+mysid 1.5 4 0.0802
## mysid 1.5 3 0.0787
## hcope 1.8 3 0.0678
## hcope+mysid+amphi 1.9 5 0.0654
## mysid+amphi 2.0 4 0.0631
## hcope+amphi 2.4 4 0.0521
## hcope+mysid+pcope 2.5 5 0.0484
## pzoop+clad+hcope 2.6 5 0.0455
## hcope+pcope 2.7 4 0.0449
## tzoop 2.8 3 0.0426
## hcope+clad 2.9 4 0.0403
## tzoop+amphi 3.1 4 0.0365
## hcope+clad+mysid 3.1 5 0.0359
## hzoop+mysid 3.4 4 0.0310
## hcope+clad+mysid+pcope 4.3 6 0.0202
## pzoop+amphi 4.3 4 0.0201
## pzoop 4.6 3 0.0171
## hzoop+pzoop 4.9 4 0.0148
## pzoop+clad 5.5 4 0.0110
## hzoop 7.0 3 0.0051
## hzoop+amphi 7.7 4 0.0036
## amphi+clad 9.1 4 0.0018
## clad 9.2 3 0.0017
## pcope+clad 10.0 4 0.0012
## pcope 11.2 3 <0.001
## pcope+amphi 11.4 4 <0.001
## amphi 11.8 3 <0.001
southmods = purrr::map(l_modelss$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="South" & !is.na(amphi) & !is.na(tzoop))))
names(southmods)=l_modelss$l_model
bbmle::AICctab(southmods,weights=T,delta=T)
## dAICc df weight
## pzoop+clad 0.0 4 0.2663
## hzoop+pzoop 0.1 4 0.2499
## pzoop+clad+hcope 0.2 5 0.2356
## pzoop 1.1 3 0.1518
## pzoop+amphi 3.3 4 0.0524
## hcope 7.6 3 0.0058
## tzoop_c 8.0 3 0.0050
## hzoop 8.0 3 0.0049
## tzoop 8.3 3 0.0041
## clad 8.7 3 0.0034
## pcope 9.2 3 0.0027
## amphi 9.2 3 0.0026
## hcope+clad 9.4 4 0.0024
## hcope+pcope 9.6 4 0.0022
## hcope+amphi 9.7 4 0.0021
## hzoop+amphi 10.1 4 0.0017
## tzoop+amphi 10.4 4 0.0015
## pcope+clad 10.4 4 0.0014
## amphi+clad 10.8 4 0.0012
## hcope+pcope+clad 11.2 5 <0.001
## pcope+amphi 11.2 4 <0.001
## hcope+pcope+amphi 11.7 5 <0.001
## hcope+pcope+amphi+clad 13.4 6 <0.001
Unlike annual model, individual zooplankton groups seems to be better predictors. The sign is not always what you would expect though.
l_modelsfw = data.frame(l_model = c("hcope+pcope+amphi",
"hcope+pcope+amphi+marfish_bsmt"))
l_modelsw = data.frame(l_model = c("mysid+amphi",
"mysid+amphi+marfish_bsmt"))
l_modelsn = data.frame(l_model = c("hcope+mysid",
"hcope+mysid+sside"))
l_modelss = data.frame(l_model = c("pzoop+clad+hcope",
"pzoop+clad+hcope+sside"))
#Midwater Trawl
fwestmods = purrr::map(l_modelsfw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="Far West" & !is.na(amphi))))
names(fwestmods)=l_modelsfw$l_model
bbmle::AICctab(fwestmods,weights=T,delta=T)
## dAICc df weight
## hcope+pcope+amphi+marfish_bsmt 0.0 6 0.904
## hcope+pcope+amphi 4.5 5 0.096
westmods = purrr::map(l_modelsw$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="West" & !is.na(amphi))))
names(westmods)=l_modelsw$l_model
bbmle::AICctab(westmods,weights=T,delta=T)
## dAICc df weight
## mysid+amphi 0.0 4 0.73
## mysid+amphi+marfish_bsmt 2.0 5 0.27
northmods = purrr::map(l_modelsn$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="North" & !is.na(sside))))
names(northmods)=l_modelsn$l_model
bbmle::AICctab(northmods,weights=T,delta=T)
## dAICc df weight
## hcope+mysid 0.0 4 0.72
## hcope+mysid+sside 1.9 5 0.28
southmods = purrr::map(l_modelss$l_model, ~lm(paste0("estfish_bsmt ~", .x),
data = filter(fdr_ds,region=="South" & !is.na(sside))))
names(southmods)=l_modelss$l_model
bbmle::AICctab(southmods,weights=T,delta=T)
## dAICc df weight
## pzoop+clad+hcope 0.0 5 0.75
## pzoop+clad+hcope+sside 2.1 6 0.25
Marine fishes important in FW but not W. Silversides not important in N and S.
This model does not use time lags.
modFW='chla~potam+flow+temp+secchi
hcope~chla+potam+flow+temp+secchi
pcope~chla+potam+flow+temp+secchi
amphi~chla+potam+flow+temp+secchi
estfish_bsmt~hcope+pcope+amphi+flow+temp+secchi+marfish_bsmt
marfish_bsmt~flow
amphi~~hcope+pcope
hcope~~pcope
'
modW='chla~potam+flow+temp+secchi
mysid~chla+potam+flow+temp+secchi
amphi~chla+potam+flow+temp+secchi
estfish_bsmt~mysid+amphi+flow+temp+secchi
amphi~~mysid
'
modN='chla~corbic+flow+temp+secchi
mysid~chla+corbic+flow+temp+secchi
hcope~chla+corbic+flow+temp+secchi
estfish_bsmt~mysid+hcope+flow+temp+secchi
hcope~~mysid
'
modS='chla~corbic+flow+temp+secchi
clad~chla+corbic+flow+temp+secchi
hcope~chla+corbic+flow+temp+secchi
pzoop~chla+corbic+flow+temp+secchi
estfish_bsmt~pzoop+clad+hcope+flow+temp+secchi
hcope~~pzoop+clad
pzoop~~clad
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 38 iterations
##
## Optimization method NLMINB
## Number of free parameters 36
##
## Used Total
## Number of observations 125 311
##
## Estimator ML
## Model Fit Test Statistic 9.217
## Degrees of freedom 9
## P-value (Chi-square) 0.418
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam 0.047 0.049 0.955 0.339 0.047 0.086
## flow 0.098 0.125 0.786 0.432 0.098 0.074
## temp 0.232 0.211 1.100 0.272 0.232 0.099
## secchi 0.083 0.084 0.980 0.327 0.083 0.092
## hcope ~
## chla 0.007 0.134 0.054 0.957 0.007 0.005
## potam -0.090 0.074 -1.229 0.219 -0.090 -0.110
## flow -0.037 0.188 -0.197 0.844 -0.037 -0.018
## temp 0.508 0.318 1.599 0.110 0.508 0.144
## secchi -0.019 0.127 -0.152 0.879 -0.019 -0.014
## pcope ~
## chla -0.009 0.082 -0.114 0.909 -0.009 -0.010
## potam -0.095 0.045 -2.119 0.034 -0.095 -0.185
## flow 0.246 0.115 2.137 0.033 0.246 0.194
## temp 0.205 0.194 1.054 0.292 0.205 0.093
## secchi -0.067 0.077 -0.862 0.389 -0.067 -0.078
## amphi ~
## chla -0.056 0.098 -0.570 0.569 -0.056 -0.040
## potam -0.019 0.054 -0.355 0.723 -0.019 -0.025
## flow -0.949 0.137 -6.939 0.000 -0.949 -0.511
## temp -0.043 0.231 -0.184 0.854 -0.043 -0.013
## secchi 0.304 0.092 3.297 0.001 0.304 0.243
## estfish_bsmt ~
## hcope -0.153 0.065 -2.346 0.019 -0.153 -0.181
## pcope -0.177 0.109 -1.633 0.102 -0.177 -0.131
## amphi -0.113 0.092 -1.224 0.221 -0.113 -0.123
## flow 0.367 0.167 2.197 0.028 0.367 0.214
## temp -0.636 0.235 -2.710 0.007 -0.636 -0.213
## secchi -0.194 0.096 -2.024 0.043 -0.194 -0.168
## marfish_bsmt 0.333 0.101 3.300 0.001 0.333 0.263
## marfish_bsmt ~
## flow -0.430 0.114 -3.760 0.000 -0.430 -0.319
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hcope ~~
## .amphi 0.052 0.074 0.700 0.484 0.052 0.063
## .pcope ~~
## .amphi -0.129 0.047 -2.762 0.006 -0.129 -0.255
## .hcope ~~
## .pcope -0.095 0.063 -1.511 0.131 -0.095 -0.136
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.506 0.064 7.906 0.000 0.506 0.976
## .hcope 1.135 0.144 7.906 0.000 1.135 0.963
## .pcope 0.425 0.054 7.906 0.000 0.425 0.918
## .amphi 0.601 0.076 7.906 0.000 0.601 0.601
## .estfish_bsmt 0.605 0.077 7.906 0.000 0.605 0.711
## .marfish_bsmt 0.474 0.060 7.906 0.000 0.474 0.898
##
## R-Square:
## Estimate
## chla 0.024
## hcope 0.037
## pcope 0.082
## amphi 0.399
## estfish_bsmt 0.289
## marfish_bsmt 0.102
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 34 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 134 311
##
## Estimator ML
## Model Fit Test Statistic 1.943
## Degrees of freedom 2
## P-value (Chi-square) 0.379
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam 0.028 0.080 0.344 0.731 0.028 0.033
## flow 0.302 0.131 2.299 0.022 0.302 0.203
## temp -0.306 0.255 -1.202 0.230 -0.306 -0.106
## secchi -0.047 0.092 -0.512 0.608 -0.047 -0.049
## mysid ~
## chla 0.097 0.080 1.201 0.230 0.097 0.093
## potam -0.169 0.075 -2.270 0.023 -0.169 -0.194
## flow -0.317 0.125 -2.546 0.011 -0.317 -0.205
## temp 0.416 0.238 1.746 0.081 0.416 0.138
## secchi -0.374 0.085 -4.379 0.000 -0.374 -0.373
## amphi ~
## chla 0.239 0.105 2.280 0.023 0.239 0.176
## potam 0.318 0.097 3.275 0.001 0.318 0.280
## flow 0.224 0.162 1.380 0.167 0.224 0.111
## temp -0.373 0.310 -1.203 0.229 -0.373 -0.095
## secchi 0.380 0.111 3.421 0.001 0.380 0.292
## estfish_bsmt ~
## mysid 0.122 0.093 1.307 0.191 0.122 0.114
## amphi -0.196 0.069 -2.823 0.005 -0.196 -0.237
## flow -0.459 0.131 -3.501 0.000 -0.459 -0.276
## temp -0.191 0.266 -0.717 0.474 -0.191 -0.059
## secchi -0.102 0.101 -1.008 0.313 -0.102 -0.095
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .mysid ~~
## .amphi -0.030 0.056 -0.534 0.593 -0.030 -0.046
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.574 0.070 8.185 0.000 0.574 0.940
## .mysid 0.498 0.061 8.185 0.000 0.498 0.748
## .amphi 0.843 0.103 8.185 0.000 0.843 0.750
## .estfish_bsmt 0.606 0.074 8.185 0.000 0.606 0.790
##
## R-Square:
## Estimate
## chla 0.060
## mysid 0.252
## amphi 0.250
## estfish_bsmt 0.210
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 36 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 129 311
##
## Estimator ML
## Model Fit Test Statistic 1.184
## Degrees of freedom 2
## P-value (Chi-square) 0.553
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic -0.117 0.067 -1.757 0.079 -0.117 -0.151
## flow -0.093 0.145 -0.638 0.524 -0.093 -0.057
## temp 0.281 0.237 1.186 0.236 0.281 0.105
## secchi -0.098 0.071 -1.370 0.171 -0.098 -0.120
## mysid ~
## chla -0.013 0.073 -0.177 0.860 -0.013 -0.013
## corbic -0.094 0.056 -1.679 0.093 -0.094 -0.118
## flow -0.429 0.120 -3.579 0.000 -0.429 -0.260
## temp 0.400 0.197 2.034 0.042 0.400 0.146
## secchi -0.369 0.059 -6.227 0.000 -0.369 -0.443
## hcope ~
## chla -0.118 0.049 -2.391 0.017 -0.118 -0.165
## corbic 0.005 0.038 0.142 0.887 0.005 0.010
## flow -0.473 0.081 -5.828 0.000 -0.473 -0.411
## temp 0.470 0.133 3.533 0.000 0.470 0.246
## secchi -0.183 0.040 -4.567 0.000 -0.183 -0.316
## estfish_bsmt ~
## mysid 0.101 0.099 1.022 0.307 0.101 0.122
## hcope 0.020 0.145 0.135 0.892 0.020 0.016
## flow -0.391 0.130 -3.007 0.003 -0.391 -0.285
## temp -0.017 0.198 -0.086 0.932 -0.017 -0.007
## secchi -0.068 0.066 -1.044 0.297 -0.068 -0.099
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .mysid ~~
## .hcope 0.132 0.024 5.383 0.000 0.132 0.538
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.531 0.066 8.031 0.000 0.531 0.931
## .mysid 0.362 0.045 8.031 0.000 0.362 0.606
## .hcope 0.166 0.021 8.031 0.000 0.166 0.572
## .estfish_bsmt 0.343 0.043 8.031 0.000 0.343 0.835
##
## R-Square:
## Estimate
## chla 0.069
## mysid 0.394
## hcope 0.428
## estfish_bsmt 0.165
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 42 iterations
##
## Optimization method NLMINB
## Number of free parameters 33
##
## Used Total
## Number of observations 130 312
##
## Estimator ML
## Model Fit Test Statistic 0.443
## Degrees of freedom 2
## P-value (Chi-square) 0.801
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic -0.036 0.065 -0.546 0.585 -0.036 -0.047
## flow -0.164 0.100 -1.636 0.102 -0.164 -0.141
## temp 0.452 0.275 1.643 0.100 0.452 0.140
## secchi -0.154 0.086 -1.781 0.075 -0.154 -0.153
## clad ~
## chla 0.384 0.077 5.007 0.000 0.384 0.380
## corbic 0.105 0.057 1.834 0.067 0.105 0.137
## flow 0.184 0.089 2.082 0.037 0.184 0.156
## temp 0.533 0.243 2.193 0.028 0.533 0.163
## secchi 0.400 0.076 5.238 0.000 0.400 0.393
## hcope ~
## chla -0.025 0.045 -0.550 0.582 -0.025 -0.045
## corbic 0.060 0.034 1.772 0.076 0.060 0.142
## flow -0.240 0.052 -4.588 0.000 -0.240 -0.368
## temp 0.396 0.144 2.754 0.006 0.396 0.219
## secchi -0.044 0.045 -0.963 0.335 -0.044 -0.077
## pzoop ~
## chla 0.239 0.081 2.954 0.003 0.239 0.255
## corbic 0.047 0.060 0.776 0.438 0.047 0.066
## flow -0.084 0.093 -0.896 0.370 -0.084 -0.077
## temp 0.054 0.257 0.212 0.832 0.054 0.018
## secchi -0.074 0.081 -0.919 0.358 -0.074 -0.079
## estfish_bsmt ~
## pzoop 0.188 0.073 2.573 0.010 0.188 0.228
## clad 0.020 0.074 0.267 0.790 0.020 0.026
## hcope -0.269 0.126 -2.144 0.032 -0.269 -0.195
## flow -0.101 0.081 -1.247 0.212 -0.101 -0.112
## temp 0.066 0.212 0.314 0.754 0.066 0.027
## secchi -0.198 0.070 -2.849 0.004 -0.198 -0.255
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hcope ~~
## .pzoop 0.006 0.026 0.239 0.811 0.006 0.021
## .clad ~~
## .hcope 0.057 0.025 2.279 0.023 0.057 0.204
## .pzoop 0.155 0.046 3.370 0.001 0.155 0.309
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.620 0.077 8.062 0.000 0.620 0.931
## .clad 0.474 0.059 8.062 0.000 0.474 0.698
## .hcope 0.166 0.021 8.062 0.000 0.166 0.794
## .pzoop 0.529 0.066 8.062 0.000 0.529 0.906
## .estfish_bsmt 0.336 0.042 8.062 0.000 0.336 0.846
##
## R-Square:
## Estimate
## chla 0.069
## clad 0.302
## hcope 0.206
## pzoop 0.094
## estfish_bsmt 0.154
#modificationindices(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
These models do use time lags.
Note: You get somewhat different answers if you use a multigroup model vs. fit each region individually. I am not entirely sure why, but I think there is some data pooling going on like in hierarchical models. I would have to look into the math. I know that if you use the multigroup framework you can impose constraints like requiring certain parameters to be the same across groups (see lavaan manual). Obviously, if data on a variable you want to use are missing from one site, you can’t use the multigroup option (you will get an error) and have to fit individually.
Clams don’t seem to have any impact on chla. Dropping dophos because strongly correlated with ammonia.
# mod1='chla~ammonia+dophos+chla_1+flow_1
# ammonia~flow_1+chla_1
# dophos~flow_1
# ammonia~~dophos'
modfww='chla~ammonia+chla_1+flow_1+secchi_1+temp_1+potam_1
ammonia~flow_1+chla_1+secchi_1+temp_1+potam_1'
modns='chla~ammonia+chla_1+flow_1+secchi_1+temp_1+corbic_1
ammonia~flow_1+chla_1+secchi_1+temp_1+corbic_1'
#you can either do a multigroup model by region
# modfit1=sem(mod1, data=fdr_ds, group = "region")
# summary(modfit1, standardized=T, rsq=T)
#
# par(mfrow=c(2,2))
# semPaths(modfit1, "std", edge.label.cex = 1, residuals = F, node.width=3, nCharNodes = 0, intercepts = F, title = T)
# #residuals(modfit1)
#or fit separately for each region
modfitFW=sem(modfww, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modfww, data=filter(fdr_ds,region=="West"))
modfitN=sem(modns, data=filter(fdr_ds,region=="North"))
modfitS=sem(modns, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 254 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.294 0.047 -6.312 0.000 -0.294 -0.362
## chla_1 0.282 0.056 5.038 0.000 0.282 0.286
## flow_1 -0.061 0.059 -1.046 0.296 -0.061 -0.065
## secchi_1 -0.000 0.053 -0.006 0.995 -0.000 -0.000
## temp_1 -0.200 0.128 -1.559 0.119 -0.200 -0.091
## potam_1 -0.000 0.042 -0.002 0.999 -0.000 -0.000
## ammonia ~
## flow_1 -0.223 0.078 -2.864 0.004 -0.223 -0.191
## chla_1 0.061 0.075 0.811 0.417 0.061 0.050
## secchi_1 -0.163 0.071 -2.300 0.021 -0.163 -0.158
## temp_1 0.006 0.173 0.032 0.975 0.006 0.002
## potam_1 0.097 0.056 1.731 0.083 0.097 0.107
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.392 0.035 11.269 0.000 0.392 0.794
## .ammonia 0.713 0.063 11.269 0.000 0.713 0.949
##
## R-Square:
## Estimate
## chla 0.206
## ammonia 0.051
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 263 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.218 0.060 -3.656 0.000 -0.218 -0.231
## chla_1 0.218 0.058 3.771 0.000 0.218 0.217
## flow_1 0.049 0.057 0.860 0.390 0.049 0.057
## secchi_1 0.084 0.052 1.624 0.104 0.084 0.101
## temp_1 -0.452 0.152 -2.971 0.003 -0.452 -0.172
## potam_1 -0.027 0.047 -0.573 0.566 -0.027 -0.035
## ammonia ~
## flow_1 -0.408 0.053 -7.681 0.000 -0.408 -0.446
## chla_1 0.104 0.060 1.740 0.082 0.104 0.097
## secchi_1 -0.051 0.054 -0.962 0.336 -0.051 -0.058
## temp_1 0.189 0.157 1.204 0.228 0.189 0.068
## potam_1 0.029 0.049 0.599 0.549 0.029 0.036
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.412 0.036 11.467 0.000 0.412 0.836
## .ammonia 0.441 0.038 11.467 0.000 0.441 0.796
##
## R-Square:
## Estimate
## chla 0.164
## ammonia 0.204
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 262 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.183 0.068 -2.710 0.007 -0.183 -0.167
## chla_1 0.224 0.061 3.648 0.000 0.224 0.222
## flow_1 -0.106 0.070 -1.514 0.130 -0.106 -0.095
## secchi_1 0.028 0.053 0.529 0.597 0.028 0.032
## temp_1 0.118 0.179 0.660 0.509 0.118 0.040
## corbic_1 -0.001 0.051 -0.029 0.977 -0.001 -0.002
## ammonia ~
## flow_1 -0.270 0.062 -4.377 0.000 -0.270 -0.266
## chla_1 0.035 0.056 0.621 0.535 0.035 0.038
## secchi_1 -0.019 0.049 -0.397 0.691 -0.019 -0.024
## temp_1 0.017 0.164 0.103 0.918 0.017 0.006
## corbic_1 0.048 0.046 1.024 0.306 0.048 0.062
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.606 0.053 11.446 0.000 0.606 0.923
## .ammonia 0.507 0.044 11.446 0.000 0.507 0.927
##
## R-Square:
## Estimate
## chla 0.077
## ammonia 0.073
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 13
##
## Used Total
## Number of observations 259 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## ammonia -0.322 0.064 -5.064 0.000 -0.322 -0.286
## chla_1 0.359 0.057 6.348 0.000 0.359 0.355
## flow_1 -0.205 0.055 -3.739 0.000 -0.205 -0.207
## secchi_1 -0.048 0.054 -0.885 0.376 -0.048 -0.050
## temp_1 0.268 0.184 1.458 0.145 0.268 0.080
## corbic_1 0.107 0.049 2.198 0.028 0.107 0.123
## ammonia ~
## flow_1 -0.065 0.053 -1.213 0.225 -0.065 -0.073
## chla_1 0.177 0.054 3.273 0.001 0.177 0.197
## secchi_1 -0.114 0.052 -2.193 0.028 -0.114 -0.136
## temp_1 -0.300 0.179 -1.680 0.093 -0.300 -0.101
## corbic_1 0.028 0.047 0.592 0.554 0.028 0.036
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.519 0.046 11.380 0.000 0.519 0.762
## .ammonia 0.495 0.043 11.380 0.000 0.495 0.920
##
## R-Square:
## Estimate
## chla 0.238
## ammonia 0.080
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=F, sig=0.05,
width=c("regress","latent","covs"),
color=c("regress","latent","covs"))
#residuals(modfitFW)
modFW='chla~chla_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+potam_1
pcope~chla_1+pcope_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
'
modW='chla~chla_1+hcope_1+flow_1+secchi_1+temp_1+potam_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+potam_1
hcope~chla_1+hcope_1+mysid_1+pcope_1+flow_1+secchi_1+temp_1+potam_1
pcope~chla_1+pcope_1+hcope_1+mysid_1+flow_1+secchi_1+temp_1+potam_1
mysid~chla_1+mysid_1+hcope_1+pcope_1+flow_1+secchi_1+temp_1+potam_1
'
modN='chla~chla_1+hcope_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
pcope~chla_1+pcope_1+hcope_1+flow_1+secchi_1+temp_1+corbic_1
mysid~chla_1+mysid_1+hcope_1+pcope_1+flow_1+secchi_1+temp_1+corbic_1
'
modS='chla~chla_1+hcope_1+clad_1+flow_1+secchi_1+temp_1+corbic_1
clad~chla_1+clad_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
hcope~chla_1+hcope_1+flow_1+pcope_1+secchi_1+temp_1+corbic_1
amphi~chla_1+amphi_1+flow_1+secchi_1+temp_1+corbic_1
pcope~chla_1+pcope_1+hcope_1+clad_1+flow_1+secchi_1+temp_1+corbic_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 40 iterations
##
## Optimization method NLMINB
## Number of free parameters 38
##
## Used Total
## Number of observations 233 311
##
## Estimator ML
## Model Fit Test Statistic 6.023
## Degrees of freedom 4
## P-value (Chi-square) 0.197
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.241 0.063 3.804 0.000 0.241 0.244
## hcope_1 0.050 0.054 0.926 0.354 0.050 0.060
## amphi_1 0.100 0.055 1.823 0.068 0.100 0.134
## flow_1 0.080 0.069 1.159 0.246 0.080 0.089
## secchi_1 0.025 0.058 0.440 0.660 0.025 0.031
## temp_1 -0.135 0.143 -0.945 0.345 -0.135 -0.062
## potam_1 -0.023 0.045 -0.509 0.611 -0.023 -0.033
## amphi ~
## chla_1 0.046 0.042 1.100 0.271 0.046 0.036
## amphi_1 0.756 0.037 20.336 0.000 0.756 0.765
## flow_1 -0.222 0.046 -4.780 0.000 -0.222 -0.187
## secchi_1 -0.019 0.039 -0.492 0.623 -0.019 -0.018
## temp_1 0.021 0.096 0.221 0.825 0.021 0.007
## potam_1 0.015 0.030 0.513 0.608 0.015 0.017
## hcope ~
## chla_1 0.070 0.081 0.858 0.391 0.070 0.051
## hcope_1 0.421 0.070 6.025 0.000 0.421 0.365
## flow_1 -0.170 0.083 -2.048 0.041 -0.170 -0.138
## pcope_1 0.141 0.085 1.654 0.098 0.141 0.103
## secchi_1 -0.004 0.074 -0.049 0.961 -0.004 -0.003
## temp_1 -0.122 0.185 -0.659 0.510 -0.122 -0.041
## potam_1 -0.145 0.058 -2.486 0.013 -0.145 -0.150
## pcope ~
## chla_1 -0.002 0.054 -0.040 0.968 -0.002 -0.002
## pcope_1 0.403 0.057 7.026 0.000 0.403 0.412
## hcope_1 -0.117 0.046 -2.514 0.012 -0.117 -0.142
## amphi_1 -0.141 0.047 -2.982 0.003 -0.141 -0.191
## flow_1 0.023 0.061 0.373 0.709 0.023 0.026
## secchi_1 0.166 0.049 3.367 0.001 0.166 0.209
## temp_1 -0.166 0.123 -1.348 0.178 -0.166 -0.078
## potam_1 -0.084 0.039 -2.159 0.031 -0.084 -0.122
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.006 0.019 0.306 0.760 0.006 0.020
## .hcope 0.037 0.036 1.008 0.313 0.037 0.066
## .pcope -0.000 0.024 -0.016 0.987 -0.000 -0.001
## .amphi ~~
## .hcope 0.011 0.024 0.458 0.647 0.011 0.030
## .pcope -0.021 0.016 -1.284 0.199 -0.021 -0.084
## .hcope ~~
## .pcope -0.056 0.031 -1.796 0.072 -0.056 -0.119
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.431 0.040 10.794 0.000 0.431 0.909
## .amphi 0.196 0.018 10.794 0.000 0.196 0.238
## .hcope 0.710 0.066 10.794 0.000 0.710 0.791
## .pcope 0.316 0.029 10.794 0.000 0.316 0.690
##
## R-Square:
## Estimate
## chla 0.091
## amphi 0.762
## hcope 0.209
## pcope 0.310
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 49 iterations
##
## Optimization method NLMINB
## Number of free parameters 51
##
## Used Total
## Number of observations 255 311
##
## Estimator ML
## Model Fit Test Statistic 13.911
## Degrees of freedom 9
## P-value (Chi-square) 0.126
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.160 0.061 2.632 0.008 0.160 0.162
## hcope_1 0.084 0.055 1.525 0.127 0.084 0.102
## flow_1 0.164 0.055 2.950 0.003 0.164 0.195
## secchi_1 0.083 0.053 1.578 0.115 0.083 0.102
## temp_1 -0.503 0.154 -3.268 0.001 -0.503 -0.197
## potam_1 -0.009 0.051 -0.169 0.866 -0.009 -0.011
## amphi ~
## chla_1 -0.021 0.047 -0.446 0.655 -0.021 -0.015
## amphi_1 0.814 0.037 22.044 0.000 0.814 0.815
## flow_1 0.024 0.041 0.597 0.550 0.024 0.020
## secchi_1 0.099 0.043 2.292 0.022 0.099 0.085
## temp_1 -0.171 0.121 -1.417 0.156 -0.171 -0.047
## potam_1 0.022 0.039 0.563 0.573 0.022 0.021
## hcope ~
## chla_1 0.098 0.072 1.363 0.173 0.098 0.082
## hcope_1 0.242 0.067 3.628 0.000 0.242 0.245
## mysid_1 0.147 0.068 2.158 0.031 0.147 0.145
## pcope_1 -0.052 0.072 -0.719 0.472 -0.052 -0.046
## flow_1 -0.013 0.069 -0.184 0.854 -0.013 -0.013
## secchi_1 0.077 0.067 1.146 0.252 0.077 0.078
## temp_1 -0.155 0.186 -0.831 0.406 -0.155 -0.050
## potam_1 -0.149 0.060 -2.462 0.014 -0.149 -0.164
## pcope ~
## chla_1 -0.049 0.055 -0.882 0.378 -0.049 -0.047
## pcope_1 0.434 0.057 7.625 0.000 0.434 0.437
## hcope_1 -0.132 0.052 -2.560 0.010 -0.132 -0.154
## mysid_1 0.150 0.053 2.815 0.005 0.150 0.171
## flow_1 0.197 0.054 3.650 0.000 0.197 0.225
## secchi_1 0.120 0.052 2.296 0.022 0.120 0.140
## temp_1 0.167 0.145 1.153 0.249 0.167 0.062
## potam_1 0.047 0.047 0.997 0.319 0.047 0.059
## mysid ~
## chla_1 0.125 0.061 2.044 0.041 0.125 0.111
## mysid_1 0.362 0.059 6.143 0.000 0.362 0.377
## hcope_1 0.042 0.057 0.729 0.466 0.042 0.045
## pcope_1 0.100 0.063 1.595 0.111 0.100 0.092
## flow_1 -0.084 0.060 -1.400 0.161 -0.084 -0.087
## secchi_1 -0.093 0.058 -1.607 0.108 -0.093 -0.099
## temp_1 0.284 0.160 1.775 0.076 0.284 0.097
## potam_1 -0.169 0.052 -3.249 0.001 -0.169 -0.197
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.004 0.020 0.173 0.862 0.004 0.011
## .hcope 0.085 0.031 2.768 0.006 0.085 0.176
## .pcope 0.009 0.024 0.387 0.699 0.009 0.024
## .mysid 0.052 0.026 1.988 0.047 0.052 0.125
## .amphi ~~
## .hcope -0.028 0.024 -1.172 0.241 -0.028 -0.074
## .pcope 0.032 0.019 1.692 0.091 0.032 0.107
## .mysid -0.017 0.021 -0.828 0.408 -0.017 -0.052
## .hcope ~~
## .pcope 0.071 0.028 2.548 0.011 0.071 0.162
## .mysid 0.116 0.031 3.693 0.000 0.116 0.238
## .pcope ~~
## .mysid 0.023 0.024 0.967 0.333 0.023 0.061
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.416 0.037 11.292 0.000 0.416 0.872
## .amphi 0.257 0.023 11.292 0.000 0.257 0.266
## .hcope 0.568 0.050 11.292 0.000 0.568 0.817
## .pcope 0.341 0.030 11.292 0.000 0.341 0.653
## .mysid 0.418 0.037 11.292 0.000 0.418 0.670
##
## R-Square:
## Estimate
## chla 0.128
## amphi 0.734
## hcope 0.183
## pcope 0.347
## mysid 0.330
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 51 iterations
##
## Optimization method NLMINB
## Number of free parameters 50
##
## Used Total
## Number of observations 252 311
##
## Estimator ML
## Model Fit Test Statistic 16.943
## Degrees of freedom 10
## P-value (Chi-square) 0.076
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.208 0.064 3.259 0.001 0.208 0.206
## hcope_1 -0.091 0.108 -0.845 0.398 -0.091 -0.061
## amphi_1 0.074 0.055 1.341 0.180 0.074 0.082
## flow_1 -0.087 0.077 -1.120 0.263 -0.087 -0.079
## secchi_1 0.029 0.056 0.513 0.608 0.029 0.033
## temp_1 0.165 0.189 0.873 0.382 0.165 0.056
## corbic_1 -0.019 0.053 -0.362 0.718 -0.019 -0.023
## amphi ~
## chla_1 0.133 0.062 2.156 0.031 0.133 0.118
## amphi_1 0.489 0.054 9.114 0.000 0.489 0.487
## flow_1 -0.047 0.067 -0.710 0.478 -0.047 -0.039
## secchi_1 0.016 0.053 0.297 0.766 0.016 0.016
## temp_1 -0.512 0.180 -2.851 0.004 -0.512 -0.156
## corbic_1 -0.041 0.051 -0.806 0.420 -0.041 -0.044
## hcope ~
## chla_1 -0.004 0.039 -0.106 0.916 -0.004 -0.006
## hcope_1 0.222 0.066 3.353 0.001 0.222 0.224
## flow_1 -0.195 0.047 -4.174 0.000 -0.195 -0.269
## pcope_1 -0.059 0.042 -1.399 0.162 -0.059 -0.085
## secchi_1 -0.035 0.035 -1.000 0.318 -0.035 -0.061
## temp_1 0.190 0.114 1.666 0.096 0.190 0.098
## corbic_1 0.022 0.032 0.687 0.492 0.022 0.040
## pcope ~
## chla_1 0.080 0.057 1.396 0.163 0.080 0.084
## pcope_1 0.357 0.062 5.778 0.000 0.357 0.359
## hcope_1 -0.134 0.098 -1.375 0.169 -0.134 -0.095
## flow_1 -0.061 0.069 -0.887 0.375 -0.061 -0.059
## secchi_1 0.015 0.052 0.282 0.778 0.015 0.018
## temp_1 0.276 0.169 1.636 0.102 0.276 0.100
## corbic_1 0.043 0.047 0.916 0.360 0.043 0.054
## mysid ~
## chla_1 0.085 0.056 1.515 0.130 0.085 0.085
## mysid_1 0.117 0.064 1.829 0.067 0.117 0.117
## hcope_1 0.108 0.106 1.020 0.308 0.108 0.073
## pcope_1 -0.029 0.062 -0.473 0.637 -0.029 -0.028
## flow_1 -0.313 0.069 -4.555 0.000 -0.313 -0.289
## secchi_1 -0.163 0.052 -3.104 0.002 -0.163 -0.189
## temp_1 0.405 0.164 2.461 0.014 0.405 0.140
## corbic_1 -0.013 0.046 -0.277 0.782 -0.013 -0.015
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .amphi 0.013 0.038 0.328 0.743 0.013 0.021
## .hcope 0.025 0.024 1.056 0.291 0.025 0.067
## .pcope -0.053 0.036 -1.490 0.136 -0.053 -0.094
## .mysid 0.064 0.035 1.833 0.067 0.064 0.116
## .amphi ~~
## .hcope 0.019 0.023 0.823 0.410 0.019 0.052
## .pcope -0.054 0.035 -1.567 0.117 -0.054 -0.099
## .mysid 0.027 0.034 0.809 0.419 0.027 0.051
## .hcope ~~
## .pcope 0.078 0.022 3.574 0.000 0.078 0.231
## .mysid 0.190 0.024 7.904 0.000 0.190 0.574
## .pcope ~~
## .mysid 0.130 0.032 4.075 0.000 0.130 0.266
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.629 0.056 11.225 0.000 0.629 0.944
## .amphi 0.593 0.053 11.225 0.000 0.593 0.713
## .hcope 0.230 0.020 11.225 0.000 0.230 0.796
## .pcope 0.501 0.045 11.225 0.000 0.501 0.846
## .mysid 0.477 0.042 11.225 0.000 0.477 0.737
##
## R-Square:
## Estimate
## chla 0.056
## amphi 0.287
## hcope 0.204
## pcope 0.154
## mysid 0.263
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 49 iterations
##
## Optimization method NLMINB
## Number of free parameters 50
##
## Used Total
## Number of observations 251 312
##
## Estimator ML
## Model Fit Test Statistic 4.845
## Degrees of freedom 10
## P-value (Chi-square) 0.901
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.267 0.062 4.337 0.000 0.267 0.264
## hcope_1 0.045 0.106 0.428 0.669 0.045 0.028
## clad_1 0.116 0.069 1.674 0.094 0.116 0.105
## flow_1 -0.197 0.067 -2.946 0.003 -0.197 -0.199
## secchi_1 -0.031 0.057 -0.547 0.585 -0.031 -0.033
## temp_1 0.275 0.198 1.392 0.164 0.275 0.082
## corbic_1 0.083 0.052 1.599 0.110 0.083 0.096
## clad ~
## chla_1 0.093 0.052 1.812 0.070 0.093 0.102
## clad_1 0.439 0.058 7.527 0.000 0.439 0.443
## flow_1 0.059 0.050 1.180 0.238 0.059 0.066
## pcope_1 -0.003 0.048 -0.060 0.952 -0.003 -0.003
## secchi_1 0.148 0.048 3.059 0.002 0.148 0.174
## temp_1 0.108 0.164 0.660 0.509 0.108 0.036
## corbic_1 0.054 0.043 1.253 0.210 0.054 0.069
## hcope ~
## chla_1 0.071 0.033 2.134 0.033 0.071 0.118
## hcope_1 0.292 0.060 4.854 0.000 0.292 0.304
## flow_1 -0.131 0.036 -3.630 0.000 -0.131 -0.223
## pcope_1 0.024 0.033 0.744 0.457 0.024 0.042
## secchi_1 0.052 0.032 1.598 0.110 0.052 0.093
## temp_1 -0.124 0.110 -1.124 0.261 -0.124 -0.063
## corbic_1 0.058 0.029 1.996 0.046 0.058 0.113
## amphi ~
## chla_1 0.055 0.061 0.901 0.368 0.055 0.055
## amphi_1 0.184 0.061 3.005 0.003 0.184 0.185
## flow_1 0.022 0.061 0.356 0.722 0.022 0.022
## secchi_1 -0.156 0.060 -2.586 0.010 -0.156 -0.166
## temp_1 -0.132 0.202 -0.653 0.514 -0.132 -0.040
## corbic_1 -0.010 0.054 -0.182 0.856 -0.010 -0.011
## pcope ~
## chla_1 0.186 0.058 3.233 0.001 0.186 0.183
## pcope_1 0.464 0.056 8.314 0.000 0.464 0.469
## hcope_1 -0.158 0.101 -1.562 0.118 -0.158 -0.097
## clad_1 0.044 0.066 0.661 0.508 0.044 0.040
## flow_1 0.044 0.062 0.707 0.480 0.044 0.044
## secchi_1 0.064 0.054 1.184 0.236 0.064 0.068
## temp_1 0.155 0.185 0.840 0.401 0.155 0.046
## corbic_1 -0.029 0.048 -0.604 0.546 -0.029 -0.034
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .clad 0.113 0.031 3.632 0.000 0.113 0.236
## .hcope 0.016 0.020 0.767 0.443 0.016 0.048
## .amphi 0.004 0.038 0.102 0.919 0.004 0.006
## .pcope -0.043 0.034 -1.264 0.206 -0.043 -0.080
## .clad ~~
## .hcope 0.032 0.017 1.850 0.064 0.032 0.118
## .amphi -0.057 0.032 -1.790 0.073 -0.057 -0.114
## .pcope 0.059 0.029 2.054 0.040 0.059 0.131
## .hcope ~~
## .amphi -0.003 0.021 -0.161 0.872 -0.003 -0.010
## .pcope 0.028 0.019 1.474 0.141 0.028 0.093
## .amphi ~~
## .pcope -0.010 0.035 -0.294 0.769 -0.010 -0.019
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.574 0.051 11.203 0.000 0.574 0.832
## .clad 0.403 0.036 11.203 0.000 0.403 0.714
## .hcope 0.179 0.016 11.203 0.000 0.179 0.737
## .amphi 0.626 0.056 11.203 0.000 0.626 0.920
## .pcope 0.499 0.045 11.203 0.000 0.499 0.714
##
## R-Square:
## Estimate
## chla 0.168
## clad 0.286
## hcope 0.263
## amphi 0.080
## pcope 0.286
#modificationindices(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
Note that because fish have more missing data, more rows get dropped (compared ‘used’ and ‘total’ number of observations to previous summaries).
If you get a warning about variances being negative, that is definitely a problem. It seems to happen when you try to create a latent variables, but the variables that go into it don’t acutally have a common trend.
modFW='estfish_bsmt~hcope_1+amphi_1+pcope_1+flow_1+secchi_1+temp_1+marfish_bsmt_1
'
modW='estfish_bsmt~hcope_1+mysid_1+pcope_1+amphi_1+flow_1+secchi_1+temp_1+marfish_bsmt_1
'
modN='estfish_bsmt~hcope_1+mysid_1+pcope_1+amphi_1+flow_1+secchi_1+temp_1+sside_1
'
modS='estfish_bsmt~hcope_1+clad_1+amphi_1+pcope_1+flow_1+secchi_1+temp_1+sside_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 21 iterations
##
## Optimization method NLMINB
## Number of free parameters 8
##
## Used Total
## Number of observations 103 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 -0.147 0.070 -2.100 0.036 -0.147 -0.189
## amphi_1 -0.077 0.103 -0.747 0.455 -0.077 -0.089
## pcope_1 0.162 0.113 1.431 0.152 0.162 0.136
## flow_1 0.377 0.176 2.143 0.032 0.377 0.245
## secchi_1 -0.054 0.121 -0.445 0.656 -0.054 -0.045
## temp_1 -0.547 0.272 -2.009 0.045 -0.547 -0.183
## marfish_bsmt_1 0.238 0.153 1.558 0.119 0.238 0.158
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.629 0.088 7.176 0.000 0.629 0.773
##
## R-Square:
## Estimate
## estfish_bsmt 0.227
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 22 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 108 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 0.166 0.113 1.469 0.142 0.166 0.151
## mysid_1 -0.136 0.126 -1.077 0.282 -0.136 -0.123
## pcope_1 -0.038 0.118 -0.322 0.747 -0.038 -0.036
## amphi_1 -0.222 0.077 -2.880 0.004 -0.222 -0.287
## flow_1 -0.070 0.145 -0.481 0.631 -0.070 -0.048
## secchi_1 -0.057 0.125 -0.456 0.648 -0.057 -0.051
## temp_1 -0.203 0.311 -0.653 0.514 -0.203 -0.065
## marfish_bsmt_1 0.146 0.108 1.349 0.177 0.146 0.143
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.600 0.082 7.348 0.000 0.600 0.856
##
## R-Square:
## Estimate
## estfish_bsmt 0.144
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 126 311
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
## Minimum Function Value 0.0000000000000
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 0.096 0.134 0.714 0.475 0.096 0.081
## mysid_1 0.012 0.086 0.143 0.887 0.012 0.015
## pcope_1 0.030 0.060 0.490 0.624 0.030 0.040
## amphi_1 0.008 0.057 0.140 0.889 0.008 0.011
## flow_1 -0.373 0.101 -3.697 0.000 -0.373 -0.353
## secchi_1 -0.031 0.070 -0.438 0.662 -0.031 -0.042
## temp_1 0.290 0.187 1.550 0.121 0.290 0.137
## sside_1 -0.059 0.072 -0.825 0.409 -0.059 -0.068
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.306 0.039 7.937 0.000 0.306 0.752
##
## R-Square:
## Estimate
## estfish_bsmt 0.248
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 9
##
## Used Total
## Number of observations 128 312
##
## Estimator ML
## Model Fit Test Statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## estfish_bsmt ~
## hcope_1 -0.044 0.125 -0.352 0.725 -0.044 -0.033
## clad_1 0.129 0.070 1.842 0.065 0.129 0.160
## amphi_1 0.102 0.062 1.635 0.102 0.102 0.137
## pcope_1 -0.106 0.057 -1.853 0.064 -0.106 -0.155
## flow_1 -0.070 0.073 -0.957 0.339 -0.070 -0.091
## secchi_1 -0.157 0.070 -2.226 0.026 -0.157 -0.192
## temp_1 0.302 0.221 1.368 0.171 0.302 0.117
## sside_1 0.272 0.093 2.927 0.003 0.272 0.247
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt 0.343 0.043 8.000 0.000 0.343 0.820
##
## R-Square:
## Estimate
## estfish_bsmt 0.180
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))